
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>语料库管理系统</title>
    <meta name="description" content="关爱残疾人，沟通无障碍。">
    <meta name="keyword" content="手语，语料库，残疾人，沟通，无障碍。">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="assets/favicon.ico" rel="icon">
    <link rel="stylesheet" href="component/pear/css/pear.css" />
    <link rel="stylesheet" href="assets/css/main.css" />
    <style>
        html, body { background-color: whitesmoke }
        .layui-container { margin: 15px auto 15px auto; }
    </style>
</head>
<body>
    <!-- header -->
    <div class="ew-header">
        <img class="layui-logo" src="assets/images/un28.svg" style="height:50px;padding: 10px;" />
        <div class="ew-nav-group">
            <div class="nav-toggle"> <i class="layui-icon layui-icon-more-vertical"> </i> </div>
            <ul class="layui-nav" lay-filter="ew-header-nav">
                <li class="layui-nav-item">
                    <a href="index.html">首页</a>
                </li>
                <li class="layui-nav-item">
                    <a href="add.html">提交语料库</a>
                </li>
                <li class="layui-nav-item layui-this">
                    <a href="search.html">语料库检索</a>
                </li>
                <li class="layui-nav-item">
                    <a href="show.html">全文手语翻译</a>
                </li>
                <li class="layui-nav-item">
                    <a href="main.html">进入管理</a>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-container" id="app">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md3">
                <div class="layui-card">
                    <div class="layui-card-header">热门词语</div>
                    <div class="layui-card-body">
                        <div id='echart' style="width:100%;height:500px"></div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md9">
                <div class="layui-card">
                    <div class="layui-card-header"> 输入</div>
                    <div class="layui-card-body">
                        <div class="layui-card">
                            <div class="layui-card-body">
                                <form class="layui-form" action="">
                                    <div class="layui-form-item">
                                        <div class="layui-form-item layui-inline">
                                            <label class="layui-form-label">词义</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="word" placeholder="请输入查询词义" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item layui-inline">
                                            <label class="layui-form-label">作者</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="author" placeholder="请输入查询作者" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item layui-inline">
                                            <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
                                                <i class="layui-icon layui-icon-search"></i>
                                                查询
                                            </button>
                                            <button type="reset" class="pear-btn pear-btn-md">
                                                <i class="layui-icon layui-icon-refresh"></i>
                                                重置
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-body">
                                <table id="user-table" lay-filter="user-table"></table>
                            </div>
                        </div>

                        <script type="text/html" id="user-toolbar">
                        </script>

                        <script type="text/html" id="user-bar">
                            <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="view">
                                <i class="layui-icon layui-icon-chart-screen">查看</i>
                            </button>
                        </script>

                        <script type="text/html" id="user-createTime">
                            {{layui.util.toDateString(d.createTime, 'yyyy-MM-dd')}}
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- footer -->
    <div class="ew-footer">
        <div class="layui-container">
            <div class="layui-row layui-col-space30">
                <div class="layui-col-md6">
                    <h2 style="font-size: 17px;" class="footer-item-title"> 技术交流</h2>
                    <p class="img-group" style="height: 105px;font-size: 15.5px;">
                        <img src="assets/images/code2.png" style="border-radius: 2px;height: 100px;width: 100px;" />
                        扫码加入技术交流QQ群<br> 备案号：云ICP备20230323XX号
                    </p>
                </div>
                <div class="layui-col-md4">
                    <h2 style="font-size: 17px;" class="footer-item-title"> 联系我们</h2>
                    <p>
                        <i class="layui-icon layui-icon-dialogue"> </i>
                        <a href="http://www.duanztai.top"> 官网 : www.duanztai.top</a>
                    </p>
                    <p style="margin-top: 2px;">
                        <i class="layui-icon layui-icon-website"> </i>
                        <a href="https://gitee.com/duanzt/shou-yu-corpus"> 仓库 : gitee.com/duanzt/shou-yu-corpus</a>
                    </p>
                </div>
                <div class="layui-col-md2">
                    <h2 style="font-size: 17px;" class="footer-item-title"> 相关链接</h2>
                    <p> <i class="layui-icon layui-icon-component"> </i> <a href="https://gitee.com/duanzt/shou-yu-corpus" target="_blank"> 组织</a> </p>
                    <p style="margin-top: 10px;">
                        <i class="layui-icon layui-icon-home"> </i>
                        <a href="https://gitee.com/duanzt/shou-yu-corpus" target="_blank"> 仓库</a>
                    </p>
                </div>
            </div>
        </div>
    </div>
    <!-- Js 部分 -->
    <script type="text/javascript" src="component/layui/layui.js"></script>
    <script type="text/javascript" src="component/pear/pear.js"></script>
    <script type="text/javascript" src="component/pear/module/echarts.js"></script>
    <script type="text/javascript" src="component/js/echarts-wordcloud.min.js"></script>
    <script>
        layui.use(['table', 'form', 'loading', 'http'], function () {
            var $ = layui.jquery;
            var form = layui.form;
            var loading = layui.loading;
            var http = layui.http;
            let table = layui.table;
            loading.Load(5, '加载中...');

            //词云
            http.ajax({
                url: '/YuLiaoK/getWordCloud',
                type: 'GET'
            }).done(function (res) {
                initwordcloud(res.result);
            });
            
            //
            let cols = [[
                { title: '词义', field: 'word' },
                { title: '作者', field: 'author', width: 150 },
                { title: '提交时间', field: 'lastDate', templet: '#user-createTime', width: 130 },
                { title: '操作', toolbar: '#user-bar', align: 'center', width: 130 }
            ]]

            table.render({
                elem: '#user-table',
                url: '/YuLiaoK/page',
                page: true,
                cols: cols,
                skin: 'line',
                toolbar: '#user-toolbar',
                defaultToolbar: [{
                    title: '刷新',
                    layEvent: 'refresh',
                    icon: 'layui-icon-refresh',
                }, 'filter', 'print', 'exports'],
                request: {
                    pageName: 'PageIndex',
                    limitName: 'PageSize'
                },
                parseData: function (res) {
                    return {
                        "count": res.result.total,
                        'statusCode': res.code,
                        'data': res.result.items
                    };
                },
                response: {
                    statusName: 'statusCode',
                    statusCode: 200
                }
            });

            table.on('tool(user-table)', function (obj) {
                if (obj.event === 'view') {
                    layer.open({
                        title: ''
                        , content: '<img src="' + obj.data.gif + '" alt="' + obj.data.word + '">'
                    });
                }
            });

            table.on('toolbar(user-table)', function (obj) {
                if (obj.event === 'refresh') {
                    window.location.reload();
                }
            });

            form.on('submit(user-query)', function (data) {
                table.reload('user-table', {
                    where: data.field
                })
                return false;
            });

            loading.loadRemove(500);
        });

        function initwordcloud(data) {
            var chart = echarts.init(document.getElementById('echart'));

            var option = {
                tooltip: {},
                series: [{
                    type: 'wordCloud',
                    gridSize: 2,
                    sizeRange: [12, 50],
                    rotationRange: [-90, 90],
                    shape: 'pentagon',
                    width: '100%',
                    height: 500,
                    drawOutOfBound: true,
                    textStyle: {
                        color: function () {
                            return 'rgb(' + [
                                Math.round(Math.random() * 160),
                                Math.round(Math.random() * 160),
                                Math.round(Math.random() * 160)
                            ].join(',') + ')';
                        }
                    },
                    emphasis: {
                        textStyle: {
                            shadowBlur: 10,
                            shadowColor: '#333'
                        }
                    },
                    data: data
                }]
            };

            chart.setOption(option);

            window.onresize = chart.resize;
        }
    </script>
</body>
</html>
